package com.augurit.gzcgwsp.jzfqwczz.common.convert;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.hwgz.entity.YwHwShSqb;
import com.augurit.gzcgwsp.jzfqwczz.common.entity.YwYnJzfqwczzCs;
import com.augurit.gzcgwsp.jzfqwczz.common.web.form.YwYnJzfqwczzCsForm;

public class YwYnJzfqwczzCsConvertor {
	public static YwYnJzfqwczzCsForm convertVoToForm(YwYnJzfqwczzCs entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwYnJzfqwczzCsForm.class);
	}
	
	public static void convertFormToVo(YwYnJzfqwczzCsForm form, YwYnJzfqwczzCs entity) {
		if (form == null) return;
        if (entity == null) entity = new YwYnJzfqwczzCs();
        
        new DozerBeanMapper().map(form, entity);
	}
	
	public static List<YwYnJzfqwczzCsForm> convertVoListToFormList(List<YwYnJzfqwczzCs> ywYnJzfqwczzCsList) {
		if(ywYnJzfqwczzCsList != null && ywYnJzfqwczzCsList.size() > 0) {
			List<YwYnJzfqwczzCsForm> ywYnJzfqwczzCsFormList = new ArrayList<YwYnJzfqwczzCsForm>();
			for(int i=0; i<ywYnJzfqwczzCsList.size(); i++) {
				ywYnJzfqwczzCsFormList.add(convertVoToForm(ywYnJzfqwczzCsList.get(i)));
			}
			return ywYnJzfqwczzCsFormList;
		}
		return null;
	}
	
	public static List<YwYnJzfqwczzCs> convertFormListToVoList(List<YwYnJzfqwczzCsForm> ywYnJzfqwczzCsFormList) {
		if(ywYnJzfqwczzCsFormList != null && ywYnJzfqwczzCsFormList.size() > 0) {
			List<YwYnJzfqwczzCs> ywYnJzfqwczzCsList = new ArrayList<YwYnJzfqwczzCs>();
			for(int i=0; i<ywYnJzfqwczzCsFormList.size(); i++) {
				YwYnJzfqwczzCs ywYnJzfqwczzCs = new YwYnJzfqwczzCs();
				convertFormToVo(ywYnJzfqwczzCsFormList.get(i), ywYnJzfqwczzCs);
				ywYnJzfqwczzCsList.add(ywYnJzfqwczzCs);
			}
			return ywYnJzfqwczzCsList;
		}
		return null;
	}
}